<template>
  <div>
    <van-popup 
      v-model="show" 
      position="right" 
      :style="{ width: '472px',height: '100%' }"  @click-overlay="showClick"
      :close-on-click-overlay="false">
      <div class="content_box">
        <div class="icon_screen">
          <img src="../../../assets/img/navbar/ic_header_preparation.png" alt="" @click="showClick">
        </div>
        <h3>设备端</h3>
        <ul class="equipment_box">
          <li 
            v-for="(item, index) in client" 
            :key="index" 
            class="equipment_list" 
            @click="currentEquipment = item.id_v"
            :class="[currentEquipment === item.id_v ? 'equipment_active': '']">
            {{item.name}}
          </li>
        </ul>
        <h3>游戏类型</h3>
        <ul class="gametype_box">
          <li 
            v-for="(item, index) in genreList" 
            :key="index" 
            class="gametype_list" 
            @click="currentGametype = item.id_v"
            :class="[currentGametype === item.id_v ? 'gametype_active': '']">
            {{item.name}}
          </li>
        </ul>
        <div class="btn">
          <van-button class="reset_btn" @click="resetClick">重置</van-button>
          <van-button class="confirm_btn" @click="screenClick">确定</van-button>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
  export default {
    props: {
      show: {
        type: Boolean,
        default: false
      },
      clientArr: {
        type: Array,
        default() {
          return []
        }
      },
      genreList: {
        type: Array,
        default() {
          return []
        }
      },
    },
    data() {
      return {
        currentEquipment: '',
        currentGametype: '',
      }
    },
    methods: {
      showClick() {
        this.$emit('show-click')
      },
      resetClick() {
        this.currentEquipment = ''
        this.currentGametype = ''
      },
      screenClick() {
        this.$emit('screen-click', this.currentEquipment,this.currentGametype)
      }
    },
    computed: {
      client() {
        if( this.clientArr) {
          const arr = this.clientArr.slice(0,2)
          return arr
        }
      }
    },
  }
</script>

<style scoped>
.content_box {
  height: 100%;
  background: #fff;
  padding: 0 54px;
}

.icon_screen {
  width: 44px;
  height: 44px;
  padding: 40px 0 40px 320px;
}

.icon_screen img {
  width: 100%;
  height: 100%;
}

.content_box h3 {
  font-size: 28px;
  color: #333;
}

.equipment_box {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 20px 0 60px 0;
}

.equipment_list {
  width: 167px;
  height: 64px;
  margin-bottom: 10px;
  border: 1px solid #e7e7e7;
  text-align: center;
  line-height: 64px;
  font-size: 24px;
  color: #242424;
  border-radius: 10px;
}

.equipment_active {
  border: 0;
  background: #2f41eb;
  color: #fff;
}

.gametype_box {
  padding: 20px 0 60px 0;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.gametype_list {
  box-sizing: border-box;
  margin-bottom: 18px;
  width: 115px;
  height: 60px;
  border: 1px solid #e7e7e7;
  text-align: center;
  line-height: 60px;
  font-size: 24px;
  color: #242424;
  border-radius: 10px;
}

.gametype_active {
  border: 0;
  background: #2f41eb;
  color: #fff;
}

.btn {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 88px;
  padding-bottom: env(safe-area-inset-bottom);
}

.reset_btn,
.confirm_btn {
  width: 50%;
  height: 100%;
  font-size: 28px;
  font-weight: 500;
  border: 0;
  box-sizing: border-box;
  border-radius: 0;
}

.confirm_btn {
  background: #2f41eb;
  color: #fff;
}

.reset_btn {
  border-top: 1px solid #999;
}
</style>